{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 导入相关的数据包\n",
    "import torch\n",
    "from torch import nn\n",
    "import torch.nn.functional as F\n",
    "from torch.utils.data import DataLoader\n",
    "from torchvision import datasets\n",
    "from torchvision.transforms import ToTensor, Lambda, Compose\n",
    "import matplotlib.pyplot as plt\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "train_data: torch.Size([60000, 28, 28])\n",
      "train_labels: torch.Size([60000])\n",
      "test_data: torch.Size([10000, 28, 28])\n",
      "test_labels: torch.Size([10000])\n"
     ]
    }
   ],
   "source": [
    "# 加载数据\n",
    "train_data = datasets.MNIST(\n",
    "    '../../data', train=True, transform=ToTensor(), download=True\n",
    ")\n",
    "test_data = datasets.MNIST(\n",
    "    '../../data', train=False, transform=ToTensor(),download=True\n",
    ")\n",
    "print(\"train_data:\", train_data.data.size())\n",
    "print(\"train_labels:\", train_data.targets.size())\n",
    "print(\"test_data:\", test_data.data.size())\n",
    "print(\"test_labels:\", test_data.targets.size())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 数据处理\n",
    "train_loader = DataLoader(dataset=train_data, batch_size=64, shuffle=True)\n",
    "test_loader = DataLoader(dataset=test_data, batch_size=64)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 定义模型\n",
    "class Net(torch.nn.Module):\n",
    "    def __init__(self):\n",
    "        super(Net, self).__init__()\n",
    "        self.conv1 = torch.nn.Sequential(\n",
    "            torch.nn.Conv2d(1, 32, 3, 1, 1),\n",
    "            torch.nn.ReLU(),\n",
    "            torch.nn.MaxPool2d(2))\n",
    "        self.conv2 = torch.nn.Sequential(\n",
    "            torch.nn.Conv2d(32, 64, 3, 1, 1),\n",
    "            torch.nn.ReLU(),\n",
    "            torch.nn.MaxPool2d(2)\n",
    "        )\n",
    "        self.conv3 = torch.nn.Sequential(\n",
    "            torch.nn.Conv2d(64, 64, 3, 1, 1),\n",
    "            torch.nn.ReLU(),\n",
    "            torch.nn.MaxPool2d(2)\n",
    "        )\n",
    "        self.dense = torch.nn.Sequential(\n",
    "            torch.nn.Linear(64 * 3 * 3, 128),\n",
    "            torch.nn.ReLU(),\n",
    "            torch.nn.Linear(128, 10)\n",
    "        )\n",
    "\n",
    "    def forward(self, x):\n",
    "        conv1_out = self.conv1(x)\n",
    "        conv2_out = self.conv2(conv1_out)\n",
    "        conv3_out = self.conv3(conv2_out)\n",
    "        res = conv3_out.view(conv3_out.size(0), -1)\n",
    "        out = self.dense(res)\n",
    "        return out"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 一个更简单的模型\n",
    "class Net2(torch.nn.Module):\n",
    "    def __init__(self):\n",
    "        super(Net2, self).__init__()\n",
    "        \n",
    "        # 卷积1操作，1个通道，10个卷积核，卷积核大小5*5\n",
    "        self.conv1 = torch.nn.Conv2d(1, 10, kernel_size=5)\n",
    "        \n",
    "        # 卷积2操作\n",
    "        self.conv2 = torch.nn.Conv2d(10, 20, kernel_size=5)\n",
    "        \n",
    "        # 最大池化\n",
    "        self.pooling = torch.nn.MaxPool2d(2)\n",
    "        \n",
    "        # 全连接\n",
    "        self.fc = torch.nn.Linear(320, 10)\n",
    " \n",
    " \n",
    "    def forward(self, x):\n",
    "        # flatten data from (n,1,28,28) to (n, 784)\n",
    "        batch_size = x.size(0)\n",
    "        x = F.relu(self.pooling(self.conv1(x)))\n",
    "        x = F.relu(self.pooling(self.conv2(x)))\n",
    "        x = x.view(batch_size, -1) # -1 此处自动算出的是320\n",
    "        x = self.fc(x)\n",
    " \n",
    "        return x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Net2(\n",
      "  (conv1): Conv2d(1, 10, kernel_size=(5, 5), stride=(1, 1))\n",
      "  (conv2): Conv2d(10, 20, kernel_size=(5, 5), stride=(1, 1))\n",
      "  (pooling): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)\n",
      "  (fc): Linear(in_features=320, out_features=10, bias=True)\n",
      ")\n",
      " [  576/60000] loss: 2.280914 accuracy:11.562500\n",
      " [ 1216/60000] loss: 2.180388 accuracy:28.437500\n",
      " [ 1856/60000] loss: 1.920868 accuracy:56.875000\n",
      " [ 2496/60000] loss: 1.461643 accuracy:68.437500\n",
      " [ 3136/60000] loss: 0.990791 accuracy:74.687500\n",
      " [ 3776/60000] loss: 0.724938 accuracy:80.625000\n",
      " [ 4416/60000] loss: 0.575880 accuracy:83.125000\n",
      " [ 5056/60000] loss: 0.484768 accuracy:84.687500\n",
      " [ 5696/60000] loss: 0.491154 accuracy:85.312500\n",
      " [ 6336/60000] loss: 0.422930 accuracy:87.343750\n",
      " [ 6976/60000] loss: 0.391028 accuracy:89.843750\n",
      " [ 7616/60000] loss: 0.362891 accuracy:90.000000\n",
      " [ 8256/60000] loss: 0.328253 accuracy:90.156250\n",
      " [ 8896/60000] loss: 0.390257 accuracy:88.906250\n",
      " [ 9536/60000] loss: 0.318485 accuracy:91.093750\n",
      " [10176/60000] loss: 0.302358 accuracy:91.562500\n",
      " [10816/60000] loss: 0.262734 accuracy:92.500000\n",
      " [11456/60000] loss: 0.294644 accuracy:91.406250\n",
      " [12096/60000] loss: 0.278341 accuracy:91.875000\n",
      " [12736/60000] loss: 0.256985 accuracy:92.343750\n",
      " [13376/60000] loss: 0.230781 accuracy:93.906250\n",
      " [14016/60000] loss: 0.218033 accuracy:93.906250\n",
      " [14656/60000] loss: 0.254102 accuracy:93.437500\n",
      " [15296/60000] loss: 0.209875 accuracy:93.906250\n",
      " [15936/60000] loss: 0.211166 accuracy:93.593750\n",
      " [16576/60000] loss: 0.265730 accuracy:92.187500\n",
      " [17216/60000] loss: 0.183693 accuracy:94.843750\n",
      " [17856/60000] loss: 0.206411 accuracy:94.218750\n",
      " [18496/60000] loss: 0.209937 accuracy:94.843750\n",
      " [19136/60000] loss: 0.226655 accuracy:93.750000\n",
      " [19776/60000] loss: 0.202677 accuracy:95.000000\n",
      " [20416/60000] loss: 0.180018 accuracy:94.531250\n",
      " [21056/60000] loss: 0.172003 accuracy:94.218750\n",
      " [21696/60000] loss: 0.149717 accuracy:95.625000\n",
      " [22336/60000] loss: 0.180358 accuracy:95.781250\n",
      " [22976/60000] loss: 0.144721 accuracy:95.312500\n",
      " [23616/60000] loss: 0.175127 accuracy:95.000000\n",
      " [24256/60000] loss: 0.169345 accuracy:94.375000\n",
      " [24896/60000] loss: 0.142129 accuracy:95.625000\n",
      " [25536/60000] loss: 0.126295 accuracy:95.781250\n",
      " [26176/60000] loss: 0.185992 accuracy:95.156250\n",
      " [26816/60000] loss: 0.155527 accuracy:95.468750\n",
      " [27456/60000] loss: 0.124740 accuracy:95.781250\n",
      " [28096/60000] loss: 0.145958 accuracy:95.000000\n",
      " [28736/60000] loss: 0.186394 accuracy:93.437500\n",
      " [29376/60000] loss: 0.229267 accuracy:92.968750\n",
      " [30016/60000] loss: 0.187021 accuracy:93.906250\n",
      " [30656/60000] loss: 0.146220 accuracy:95.000000\n",
      " [31296/60000] loss: 0.112122 accuracy:96.093750\n",
      " [31936/60000] loss: 0.156720 accuracy:94.687500\n",
      " [32576/60000] loss: 0.135788 accuracy:96.562500\n",
      " [33216/60000] loss: 0.170278 accuracy:95.000000\n",
      " [33856/60000] loss: 0.111998 accuracy:97.031250\n",
      " [34496/60000] loss: 0.100310 accuracy:97.343750\n",
      " [35136/60000] loss: 0.154053 accuracy:94.531250\n",
      " [35776/60000] loss: 0.123843 accuracy:96.562500\n",
      " [36416/60000] loss: 0.180714 accuracy:94.843750\n",
      " [37056/60000] loss: 0.134331 accuracy:97.031250\n",
      " [37696/60000] loss: 0.128114 accuracy:96.562500\n",
      " [38336/60000] loss: 0.129985 accuracy:96.250000\n",
      " [38976/60000] loss: 0.156647 accuracy:94.687500\n",
      " [39616/60000] loss: 0.116271 accuracy:97.343750\n",
      " [40256/60000] loss: 0.128437 accuracy:97.031250\n",
      " [40896/60000] loss: 0.124914 accuracy:96.250000\n",
      " [41536/60000] loss: 0.105201 accuracy:97.031250\n",
      " [42176/60000] loss: 0.100971 accuracy:97.031250\n",
      " [42816/60000] loss: 0.124228 accuracy:96.093750\n",
      " [43456/60000] loss: 0.108192 accuracy:96.093750\n",
      " [44096/60000] loss: 0.130779 accuracy:96.093750\n",
      " [44736/60000] loss: 0.126538 accuracy:96.093750\n",
      " [45376/60000] loss: 0.121757 accuracy:96.093750\n",
      " [46016/60000] loss: 0.136367 accuracy:95.468750\n",
      " [46656/60000] loss: 0.097132 accuracy:96.406250\n",
      " [47296/60000] loss: 0.082121 accuracy:97.343750\n",
      " [47936/60000] loss: 0.086883 accuracy:97.500000\n",
      " [48576/60000] loss: 0.147659 accuracy:96.718750\n",
      " [49216/60000] loss: 0.118789 accuracy:96.718750\n",
      " [49856/60000] loss: 0.066502 accuracy:97.968750\n",
      " [50496/60000] loss: 0.111139 accuracy:96.875000\n",
      " [51136/60000] loss: 0.080579 accuracy:97.812500\n",
      " [51776/60000] loss: 0.096930 accuracy:97.500000\n",
      " [52416/60000] loss: 0.077471 accuracy:97.500000\n",
      " [53056/60000] loss: 0.094399 accuracy:97.968750\n",
      " [53696/60000] loss: 0.100608 accuracy:96.718750\n",
      " [54336/60000] loss: 0.134510 accuracy:96.562500\n",
      " [54976/60000] loss: 0.109031 accuracy:96.250000\n",
      " [55616/60000] loss: 0.092562 accuracy:97.656250\n",
      " [56256/60000] loss: 0.096055 accuracy:97.343750\n",
      " [56896/60000] loss: 0.105309 accuracy:96.718750\n",
      " [57536/60000] loss: 0.096273 accuracy:96.718750\n",
      " [58176/60000] loss: 0.099093 accuracy:96.406250\n",
      " [58816/60000] loss: 0.091617 accuracy:97.187500\n",
      " [59456/60000] loss: 0.078901 accuracy:98.437500\n",
      "第0轮： --accuracy:97.390\n",
      " [  576/60000] loss: 0.095585 accuracy:96.875000\n",
      " [ 1216/60000] loss: 0.091007 accuracy:96.875000\n",
      " [ 1856/60000] loss: 0.056793 accuracy:98.125000\n",
      " [ 2496/60000] loss: 0.103592 accuracy:97.812500\n",
      " [ 3136/60000] loss: 0.084781 accuracy:97.343750\n",
      " [ 3776/60000] loss: 0.071141 accuracy:97.812500\n",
      " [ 4416/60000] loss: 0.137195 accuracy:96.406250\n",
      " [ 5056/60000] loss: 0.132365 accuracy:96.562500\n",
      " [ 5696/60000] loss: 0.117394 accuracy:96.875000\n",
      " [ 6336/60000] loss: 0.089425 accuracy:96.875000\n",
      " [ 6976/60000] loss: 0.082076 accuracy:97.187500\n",
      " [ 7616/60000] loss: 0.059022 accuracy:98.281250\n",
      " [ 8256/60000] loss: 0.077087 accuracy:97.187500\n",
      " [ 8896/60000] loss: 0.064256 accuracy:98.281250\n",
      " [ 9536/60000] loss: 0.069727 accuracy:97.812500\n",
      " [10176/60000] loss: 0.092998 accuracy:96.406250\n",
      " [10816/60000] loss: 0.107761 accuracy:97.500000\n",
      " [11456/60000] loss: 0.089746 accuracy:97.343750\n",
      " [12096/60000] loss: 0.089925 accuracy:97.343750\n",
      " [12736/60000] loss: 0.060385 accuracy:98.281250\n",
      " [13376/60000] loss: 0.092151 accuracy:96.875000\n",
      " [14016/60000] loss: 0.102128 accuracy:96.562500\n",
      " [14656/60000] loss: 0.074085 accuracy:97.812500\n",
      " [15296/60000] loss: 0.143826 accuracy:96.093750\n",
      " [15936/60000] loss: 0.075582 accuracy:97.187500\n",
      " [16576/60000] loss: 0.060674 accuracy:97.500000\n",
      " [17216/60000] loss: 0.086112 accuracy:97.500000\n",
      " [17856/60000] loss: 0.079021 accuracy:97.500000\n",
      " [18496/60000] loss: 0.110942 accuracy:96.875000\n",
      " [19136/60000] loss: 0.087140 accuracy:97.031250\n",
      " [19776/60000] loss: 0.097911 accuracy:97.968750\n",
      " [20416/60000] loss: 0.103257 accuracy:97.656250\n",
      " [21056/60000] loss: 0.074368 accuracy:97.656250\n",
      " [21696/60000] loss: 0.092074 accuracy:97.656250\n",
      " [22336/60000] loss: 0.064906 accuracy:97.656250\n",
      " [22976/60000] loss: 0.075286 accuracy:97.187500\n",
      " [23616/60000] loss: 0.096893 accuracy:97.343750\n",
      " [24256/60000] loss: 0.095282 accuracy:97.968750\n",
      " [24896/60000] loss: 0.069780 accuracy:97.812500\n",
      " [25536/60000] loss: 0.095025 accuracy:96.562500\n",
      " [26176/60000] loss: 0.075219 accuracy:98.125000\n",
      " [26816/60000] loss: 0.087563 accuracy:97.343750\n",
      " [27456/60000] loss: 0.089266 accuracy:97.343750\n",
      " [28096/60000] loss: 0.064956 accuracy:97.656250\n",
      " [28736/60000] loss: 0.099840 accuracy:97.343750\n",
      " [29376/60000] loss: 0.064763 accuracy:98.437500\n",
      " [30016/60000] loss: 0.073409 accuracy:97.968750\n",
      " [30656/60000] loss: 0.106447 accuracy:97.500000\n",
      " [31296/60000] loss: 0.087699 accuracy:97.500000\n",
      " [31936/60000] loss: 0.073918 accuracy:97.343750\n",
      " [32576/60000] loss: 0.072431 accuracy:97.500000\n",
      " [33216/60000] loss: 0.073448 accuracy:97.187500\n",
      " [33856/60000] loss: 0.072995 accuracy:97.031250\n",
      " [34496/60000] loss: 0.083157 accuracy:97.031250\n",
      " [35136/60000] loss: 0.093865 accuracy:97.031250\n",
      " [35776/60000] loss: 0.090258 accuracy:97.812500\n",
      " [36416/60000] loss: 0.068391 accuracy:98.281250\n",
      " [37056/60000] loss: 0.068540 accuracy:97.343750\n",
      " [37696/60000] loss: 0.064346 accuracy:97.968750\n",
      " [38336/60000] loss: 0.057118 accuracy:98.281250\n",
      " [38976/60000] loss: 0.064885 accuracy:98.125000\n",
      " [39616/60000] loss: 0.079417 accuracy:97.968750\n",
      " [40256/60000] loss: 0.063538 accuracy:97.968750\n",
      " [40896/60000] loss: 0.055755 accuracy:98.593750\n",
      " [41536/60000] loss: 0.057159 accuracy:97.968750\n",
      " [42176/60000] loss: 0.086786 accuracy:97.031250\n",
      " [42816/60000] loss: 0.065063 accuracy:97.500000\n",
      " [43456/60000] loss: 0.097635 accuracy:96.718750\n",
      " [44096/60000] loss: 0.050680 accuracy:98.906250\n",
      " [44736/60000] loss: 0.084232 accuracy:98.125000\n",
      " [45376/60000] loss: 0.098630 accuracy:97.031250\n",
      " [46016/60000] loss: 0.077528 accuracy:96.718750\n",
      " [46656/60000] loss: 0.083977 accuracy:97.031250\n",
      " [47296/60000] loss: 0.075093 accuracy:98.281250\n",
      " [47936/60000] loss: 0.060187 accuracy:98.281250\n",
      " [48576/60000] loss: 0.073720 accuracy:97.812500\n",
      " [49216/60000] loss: 0.042245 accuracy:98.750000\n",
      " [49856/60000] loss: 0.061029 accuracy:97.968750\n",
      " [50496/60000] loss: 0.077090 accuracy:97.031250\n",
      " [51136/60000] loss: 0.068958 accuracy:97.656250\n",
      " [51776/60000] loss: 0.084671 accuracy:97.343750\n",
      " [52416/60000] loss: 0.103799 accuracy:97.343750\n",
      " [53056/60000] loss: 0.081892 accuracy:98.125000\n",
      " [53696/60000] loss: 0.070818 accuracy:97.500000\n",
      " [54336/60000] loss: 0.076732 accuracy:97.500000\n",
      " [54976/60000] loss: 0.090833 accuracy:97.187500\n",
      " [55616/60000] loss: 0.068447 accuracy:97.500000\n",
      " [56256/60000] loss: 0.091966 accuracy:98.125000\n",
      " [56896/60000] loss: 0.078076 accuracy:97.500000\n",
      " [57536/60000] loss: 0.070918 accuracy:97.812500\n",
      " [58176/60000] loss: 0.069551 accuracy:97.500000\n",
      " [58816/60000] loss: 0.057110 accuracy:98.750000\n",
      " [59456/60000] loss: 0.045783 accuracy:98.906250\n",
      "第1轮： --accuracy:98.370\n",
      " [  576/60000] loss: 0.060410 accuracy:97.500000\n",
      " [ 1216/60000] loss: 0.088471 accuracy:97.656250\n",
      " [ 1856/60000] loss: 0.056255 accuracy:98.125000\n",
      " [ 2496/60000] loss: 0.074086 accuracy:98.125000\n",
      " [ 3136/60000] loss: 0.057984 accuracy:97.656250\n",
      " [ 3776/60000] loss: 0.059514 accuracy:98.437500\n",
      " [ 4416/60000] loss: 0.049391 accuracy:98.750000\n",
      " [ 5056/60000] loss: 0.085315 accuracy:97.187500\n",
      " [ 5696/60000] loss: 0.056431 accuracy:98.437500\n",
      " [ 6336/60000] loss: 0.056773 accuracy:97.968750\n",
      " [ 6976/60000] loss: 0.059240 accuracy:98.593750\n",
      " [ 7616/60000] loss: 0.059301 accuracy:98.437500\n",
      " [ 8256/60000] loss: 0.074273 accuracy:97.500000\n",
      " [ 8896/60000] loss: 0.087182 accuracy:97.656250\n",
      " [ 9536/60000] loss: 0.079979 accuracy:97.500000\n",
      " [10176/60000] loss: 0.066553 accuracy:97.500000\n",
      " [10816/60000] loss: 0.042203 accuracy:99.218750\n",
      " [11456/60000] loss: 0.042110 accuracy:98.906250\n",
      " [12096/60000] loss: 0.079073 accuracy:97.500000\n",
      " [12736/60000] loss: 0.079645 accuracy:98.125000\n",
      " [13376/60000] loss: 0.052115 accuracy:98.281250\n",
      " [14016/60000] loss: 0.064827 accuracy:98.437500\n",
      " [14656/60000] loss: 0.071490 accuracy:97.812500\n",
      " [15296/60000] loss: 0.064371 accuracy:97.812500\n",
      " [15936/60000] loss: 0.054364 accuracy:99.062500\n",
      " [16576/60000] loss: 0.065805 accuracy:97.812500\n",
      " [17216/60000] loss: 0.072225 accuracy:97.187500\n",
      " [17856/60000] loss: 0.058286 accuracy:98.281250\n",
      " [18496/60000] loss: 0.049941 accuracy:98.593750\n",
      " [19136/60000] loss: 0.038642 accuracy:98.593750\n",
      " [19776/60000] loss: 0.043225 accuracy:99.062500\n",
      " [20416/60000] loss: 0.061134 accuracy:98.281250\n",
      " [21056/60000] loss: 0.042797 accuracy:98.750000\n",
      " [21696/60000] loss: 0.049593 accuracy:98.593750\n",
      " [22336/60000] loss: 0.056118 accuracy:98.593750\n",
      " [22976/60000] loss: 0.101507 accuracy:97.187500\n",
      " [23616/60000] loss: 0.074321 accuracy:98.125000\n",
      " [24256/60000] loss: 0.080119 accuracy:97.812500\n",
      " [24896/60000] loss: 0.040882 accuracy:99.062500\n",
      " [25536/60000] loss: 0.046395 accuracy:98.437500\n",
      " [26176/60000] loss: 0.046081 accuracy:98.906250\n",
      " [26816/60000] loss: 0.056152 accuracy:98.437500\n",
      " [27456/60000] loss: 0.047680 accuracy:98.593750\n",
      " [28096/60000] loss: 0.053006 accuracy:97.968750\n",
      " [28736/60000] loss: 0.048972 accuracy:98.437500\n",
      " [29376/60000] loss: 0.046027 accuracy:98.906250\n",
      " [30016/60000] loss: 0.063182 accuracy:98.125000\n",
      " [30656/60000] loss: 0.046265 accuracy:98.281250\n",
      " [31296/60000] loss: 0.076169 accuracy:98.437500\n",
      " [31936/60000] loss: 0.062944 accuracy:98.281250\n",
      " [32576/60000] loss: 0.061454 accuracy:98.281250\n",
      " [33216/60000] loss: 0.064075 accuracy:98.125000\n",
      " [33856/60000] loss: 0.058312 accuracy:97.968750\n",
      " [34496/60000] loss: 0.046956 accuracy:98.437500\n",
      " [35136/60000] loss: 0.044602 accuracy:98.437500\n",
      " [35776/60000] loss: 0.058468 accuracy:98.750000\n",
      " [36416/60000] loss: 0.060916 accuracy:97.968750\n",
      " [37056/60000] loss: 0.043809 accuracy:98.750000\n",
      " [37696/60000] loss: 0.042195 accuracy:98.750000\n",
      " [38336/60000] loss: 0.051630 accuracy:98.125000\n",
      " [38976/60000] loss: 0.086665 accuracy:98.281250\n",
      " [39616/60000] loss: 0.073381 accuracy:97.968750\n",
      " [40256/60000] loss: 0.038912 accuracy:98.750000\n",
      " [40896/60000] loss: 0.072194 accuracy:97.500000\n",
      " [41536/60000] loss: 0.073114 accuracy:97.812500\n",
      " [42176/60000] loss: 0.064237 accuracy:98.437500\n",
      " [42816/60000] loss: 0.053760 accuracy:98.437500\n",
      " [43456/60000] loss: 0.069722 accuracy:98.125000\n",
      " [44096/60000] loss: 0.049780 accuracy:98.437500\n",
      " [44736/60000] loss: 0.037979 accuracy:99.062500\n",
      " [45376/60000] loss: 0.077820 accuracy:97.968750\n",
      " [46016/60000] loss: 0.058487 accuracy:98.437500\n",
      " [46656/60000] loss: 0.044220 accuracy:98.906250\n",
      " [47296/60000] loss: 0.032235 accuracy:98.750000\n",
      " [47936/60000] loss: 0.051595 accuracy:98.281250\n",
      " [48576/60000] loss: 0.046348 accuracy:98.125000\n",
      " [49216/60000] loss: 0.059056 accuracy:98.437500\n",
      " [49856/60000] loss: 0.049153 accuracy:98.593750\n",
      " [50496/60000] loss: 0.037952 accuracy:98.437500\n",
      " [51136/60000] loss: 0.065099 accuracy:98.437500\n",
      " [51776/60000] loss: 0.065938 accuracy:98.125000\n",
      " [52416/60000] loss: 0.068321 accuracy:97.968750\n",
      " [53056/60000] loss: 0.053224 accuracy:98.593750\n",
      " [53696/60000] loss: 0.036986 accuracy:98.750000\n",
      " [54336/60000] loss: 0.072746 accuracy:97.656250\n",
      " [54976/60000] loss: 0.058610 accuracy:98.593750\n",
      " [55616/60000] loss: 0.065233 accuracy:96.875000\n",
      " [56256/60000] loss: 0.052651 accuracy:98.750000\n",
      " [56896/60000] loss: 0.040445 accuracy:98.750000\n",
      " [57536/60000] loss: 0.033371 accuracy:98.906250\n",
      " [58176/60000] loss: 0.038186 accuracy:98.593750\n",
      " [58816/60000] loss: 0.054134 accuracy:98.437500\n",
      " [59456/60000] loss: 0.031246 accuracy:98.906250\n",
      "第2轮： --accuracy:98.510\n"
     ]
    }
   ],
   "source": [
    "# 梯度下降算法\n",
    "model = Net2()\n",
    "print(model)\n",
    "optimizer = torch.optim.Adam(model.parameters())\n",
    "# optimizer = torch.optim.SGD(model.parameters(),lr=0.01,momentum=0.5)\n",
    "loss_func = torch.nn.CrossEntropyLoss()\n",
    "\n",
    "# device = torch.device(\"cuda:0\" if torch.cuda.is_available() else \"cpu\")\n",
    "\n",
    "\n",
    "running_loss_list = []\n",
    "running_accuracy_list = []\n",
    "\n",
    "loss_list = []\n",
    "accuracy_list = []\n",
    "\n",
    "\n",
    "def train():\n",
    "    # 定义训练的损失。进行多次batch梯度下降\n",
    "    model.train()\n",
    "    size = len(train_loader.dataset)\n",
    "    running_loss = 0\n",
    "    total = 0\n",
    "    correct = 0\n",
    "    for step,dt in enumerate(train_loader):\n",
    "        batch_x,batch_y=dt\n",
    "        # print(xb.shape,xb.dtype)\n",
    "        # xb,yb = xb.to(device),yb.to(device)\n",
    "        outputs = model(batch_x)\n",
    "        loss = loss_func(outputs,batch_y.long())\n",
    "        optimizer.zero_grad()\n",
    "        loss.backward()\n",
    "        optimizer.step()\n",
    "\n",
    "        running_loss+=loss.item()\n",
    "        total += batch_y.size(0)\n",
    "        _,predicted = torch.max(outputs,1)\n",
    "        correct += (predicted == batch_y).sum().item()\n",
    "        interval = 10\n",
    "        if step % interval == interval-1:\n",
    "            loss_temp = running_loss/interval\n",
    "            current = step * len(batch_x)\n",
    "            accuracy = 100*correct/total\n",
    "            running_loss_list.append(loss_temp)\n",
    "            running_accuracy_list.append(accuracy)\n",
    "            \n",
    "            running_loss=0 \n",
    "            total = 0\n",
    "            correct = 0\n",
    "            print(f\" [{current:>5d}/{size:>5d}] loss: {loss_temp:>7f} accuracy:{accuracy:>7f}\")\n",
    "\n",
    "def test():\n",
    "    # 训练一个epoch进行一次测试\n",
    "    model.eval()\n",
    "    correct = 0.\n",
    "    total =0.\n",
    "    with torch.no_grad():\n",
    "        for batch_x,batch_y in test_loader:\n",
    "            outputs = model(batch_x)\n",
    "            # print(outputs.shape)\n",
    "            _,predicted = torch.max(outputs,1)\n",
    "\n",
    "            total += batch_y.size(0)\n",
    "            correct += (predicted == batch_y).sum().item()\n",
    "    \n",
    "    accuracy = 100*correct/total\n",
    "    # loss_list.append(loss.item())\n",
    "    accuracy_list.append(accuracy)\n",
    "    print(\"第{}轮：\".format(epoch),\"--accuracy:{:.3f}\".format(accuracy))\n",
    "\n",
    "\n",
    "epochs = 3\n",
    "\n",
    "for epoch in range(epochs):\n",
    "    train()\n",
    "    test()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD4CAYAAAD8Zh1EAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAAmhklEQVR4nO3deXxU1f3/8deZNQtJICHsS9g3UUAEVMS17nX72p9ad61La1u7Wu2idvt+W6370kqVqrSKrVqldUFUkEVBAgISQiCELSGQhWxkn5nz+2MmQ1hCAkTC3Lyfj0ceTGZuZj4nE95z7rnnnmustYiISOxzdXQBIiLSPhToIiIOoUAXEXEIBbqIiEMo0EVEHMLTUS/cvXt3m5GR0VEvLyISk5YvX15irU0/0GMdFugZGRlkZmZ21MuLiMQkY8yWlh7TkIuIiEMo0EVEHEKBLiLiEAp0ERGHUKCLiDiEAl1ExCEU6CIiDhFzgb5uRyV/fH8dFbWNHV2KiMgxJeYCfWtpDX+ev5EtpdUdXYqIyDEl5gK9X7cEAPLLaju4EhGRY0vMBXrfbvEA5JfVdHAlIiLHlpgL9JR4L0lxHvXQRUT2EXOBDuFhlwIFuojIXmI00OPVQxcR2UcMB3oN1tqOLkVE5JgRk4Het2s81Q1Byms0F11EpElMBnrT1MWCcg27iIg0iclAT0/yA1C8u76DKxEROXbEZKB38YevnFdTH+zgSkREjh0xGegJPjcA1Q2BDq5EROTYEZOBvqeHrkAXEWkSk4Ge4G/qoWvIRUSkSUwGus/twuMyVKuHLiISFZOBbowh0e+hRj10EZGomAx0gESfWz10EZFmYjbQE/wezXIREWkmZgM93EPXkIuISJPYDXS/hxr10EVEomI20BN8HvXQRUSaidlAT/S7NYYuItJMq4FujOlvjJlnjFlrjMkyxtx9gG2MMeZJY0yuMWa1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4oZxphEY0xS023gXGANe18B6kbg7Y6psF201JbZwA2RWRNTgIpmu/jHvH3GjS8n/L5BuF1XG2P8xphBwDDg86NdX1sZYwzhC9RkW2sfbfZQTL9vLbXLKe9bizr6qOyhfhE+yr6e8FHoX3R0PUfYlsGEj6yvArKa2gOkAR8BG4APgdSOrrWN7XmV8G5sI+ExyFtbagvhWRLPRN7HL4GJHV3/IbZrZqTu1YTDoHez7X8RaVcOcEFH199K26YSHk5ZDayMfF0Y6+/bQdrliPetpS+d+i8i4hCxNuQiIiItUKCLiDiEAl1ExCEU6CIiDqFAFxFxCAW6iIhDKNBFRBzi/wPxL+PWFRWEiQAAAABJRU5ErkJggg==\n",
      "text/plain": "<Figure size 432x288 with 1 Axes>"
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# matplotlib可视化\n",
    "import matplotlib.pyplot as plt\n",
    "fig = plt.figure(1)\n",
    "plt.plot(running_loss_list)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD4CAYAAAAXUaZHAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAAldElEQVR4nO3deXxU9b3/8dc3mewkgYQQICwJO8gii4i44YJFreJe79UWq5bW1lbbepXa22rbe1u1Wq2/Vr3WDetWClSs1gURVIosYd8hbFkgC2Ql22zf3x8zGRJI2AYNc/J+Ph55ZObMmZnvNyd55zuf8z3nGGstIiLiLFHt3QARETn1FO4iIg6kcBcRcSCFu4iIAyncRUQcyNXeDQDo2rWrzc7Obu9miIhElJUrV+631ma09thpEe7Z2dnk5ua2dzNERCKKMWZPW4+pLCMi4kAKdxERB1K4i4g40DHD3RjzkjGm1BizodmyNGP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5o9F8rZrpV+O2m6Hi+RwLwJ6N7vfK7gsYllri4LfS4F/EPgoWNL0UTf4vbT9WhiWtvoR8dvRWltirfVZa/3AXzj0ET7i+maMiSEQgK9ba+cGF0f8tmutX07abq2J5HBfAQw0xuQYY2KBm4F32rlNJ80Yk2SMSW66DVwGbCDQp2nB1aYB89qnhWFrqx/vAN8KzryYAFQ1KwFEhMPqzNcS2G4Q6NvNxpg4Y0wOMBBY/lW373gZYwzwIrDZWvuHZg9F9LZrq19O2W5tau89uuF8Edhbv43A3uyft3d7wuxLPwJ76NcCG5v6A6QDC4DtwMdAWnu39Tj68iaBj7keAvXKO9rqB4GZFn8ObsP1wLj2bv9J9O2vwbavIxAMPZqt//Ng37YCl7d3+4/Rt/MIlFzWAWuCX1dE+rY7Sr8csd3a+tLpB0REHCiSyzIiItIGhbuIiAMp3EVEHEjhLiLiQAp3EREHUriLiDiQwl1ExIH+P0WN4r8WWSF1AAAAAElFTkSuQmCC\n",
      "text/plain": "<Figure size 432x288 with 1 Axes>"
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# matplotlib可视化accuracy\n",
    "fit = plt.figure(2)\n",
    "plt.plot(running_accuracy_list)\n",
    "plt.show()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3.8.10 64-bit ('pysyft': virtualenvwrapper)",
   "name": "python3810jvsc74a57bd054f0cca124f38538f0af9da5035feb8330e039430efda7f6532c7bec2bbfbd8a"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.10"
  },
  "orig_nbformat": 2
 },
 "nbformat": 4,
 "nbformat_minor": 2
}